package com.graduate.twentyone.mapper;


import com.graduate.twentyone.domain.Cate;
import com.graduate.twentyone.domain.Echarts;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface CateMapper {

    @Select("select * from cate  order by  cate_id  desc")
    List<Cate> queryAll();

    @Update("update cate set cate_name=#{cate_name}where cate_id = #{cate_id}")
    Integer updateById(Cate cate);

    @Delete("delete from cate where cate_id=#{cate_id}")
    Integer deleteById(Integer cate_id);

    @Insert("insert into cate (cate_id,cate_name) values (null,#{cate_name})")
    Integer addOne(String cate_name);

    //cate=1为其他类
    @Update("update food set mold=1 where mold = #{cate_id}")
    void deleteByIdAndFoods(Integer cate_id);

    @Select("SELECT count(*) as count,cate_name FROM food left JOIN cate on mold=cate_id GROUP BY mold")
    List<Echarts> queryEcharts();
}
